"use server";
import Title from 'antd/es/typography/Title'
import './index.css'
import BankList from '@/components/BankList'
import { listBankUsingPost } from '@/api/BankApi'

/**
 * 主页
 * @constructor
 */
export default async function BanksPage() {
  let bankList = [];
  try {
    const res = await listBankUsingPost({
      pageSize: 200,
      sortField: "createTime",
      sortOrder: "descend",
    });
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-expect-error
    bankList = res.data.records ?? [];
  } catch (e) {
    console.error("Failed to fetch bank list:", e);
  }

  return (
    <div id="homePage" className="max-width-content">
      <Title level={3}>全部题库</Title>
      <BankList bankList={bankList} />
    </div>
  );
}
